package com.five.wisdomEat.controller;

import com.five.wisdomEat.entity.BusinessInfo;
import com.five.wisdomEat.entity.ResponseMessage;
import com.five.wisdomEat.service.BusinessInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/businessinfo")
public class BusinessInfoController {
    @Autowired
    private BusinessInfoService service;

    @GetMapping("/getBusinessList")
    public ResponseMessage selectBusinessList(){
        return service.selectBusinessList();
    }

    @PostMapping("/insertBusiness")
    public ResponseMessage insertBusiness(String bNumber, String bName, String bAddress, String bPhone){
        BusinessInfo businessInfo = new BusinessInfo();
        businessInfo.setBNumber(bNumber);
        businessInfo.setBName(bName);
        businessInfo.setBPhone(bPhone);
        businessInfo.setBAddress(bAddress);
        return service.insertBusiness(businessInfo);
    }

    @PostMapping("/updateBusiness")
    public ResponseMessage updateBusiness(String bNumber,String bName, String bAddress, String bPhone){
        BusinessInfo businessInfo = new BusinessInfo();
        businessInfo.setBNumber(bNumber);
        businessInfo.setBName(bName);
        businessInfo.setBPhone(bPhone);
        businessInfo.setBAddress(bAddress);
        return service.updateBusiness(businessInfo);
    }

    @PostMapping("/deleteBusiness")
    public ResponseMessage deleteBusiness(String bNumber){
        return service.deleteBusiness(bNumber);
    }

    @GetMapping("/getBusinessListByBNumber")
    public ResponseMessage selectBusinessListByBNumber(String bNumber){
        return service.selectBusinessListByBNumber(bNumber);
    }

    @PostMapping("/onSaleBusiness")
    public ResponseMessage onSaleBusiness(String bNumber){
        return service.onSaleBusiness(bNumber);
    }

    @PostMapping("/offShelfBusiness")
    public ResponseMessage offShelfBusiness(String bNumber){
        return service.offShelfBusiness(bNumber);
    }

    @PostMapping("/rectifyBusiness")
    public ResponseMessage rectifyBusiness(String bNumber){
        return service.rectifyBusiness(bNumber);
    }

    @GetMapping("/getBusinessStatus")
    public ResponseMessage selectBusinessStatus(){
        return service.selectBusinessStatus();
    }

    @GetMapping("/selectBusinessCount")
    public ResponseMessage selectBusinessCount(){return service.selectBusinessCount();}
}
